#include "iostream"
#include "string"

using namespace std;


template<class T1, class T2>
class Person001 {
public:
    T1 name;
    T2 age;

    Person001(T1 name, T2 age) : name(name), age(age) {}

    void showPerson() {
        std::cout << name << age << endl;
    }
};

//1、指定传入类型 -- 最常用
void printPerson1(Person001<string, int> &p) {
    p.showPerson();
}

void test01() {
    Person001<string, int> p("孙悟空", 100);
    printPerson1(p);
}

//2、参数模板化
template<class T1, class T2>
void printPerson2(Person001<T1, T2> &p) {
    p.showPerson();
    cout << "T1的类型" << typeid(T1).name() << endl;
    cout << "T2的类型" << typeid(T2).name() << endl;
}

void test02() {
    Person001<string, int> p("猪八戒", 100);
    printPerson2<string, int>(p);
}

//3、整个类模板化
template<class T>
void printPerson3(T &p) {
    p.showPerson();
    cout << "T的类型" << typeid(T).name() << endl;
}

void test03() {
    Person001<string, int> p("唐僧", 100);
    printPerson3<>(p);
}


int main() {
    test01();
    test02();
    test03();
}